import java.io.*;
public class Test {

    public static void main(String[] args) throws IOException {

		testWrite();

        testRead();

    }

    private static void testRead() throws IOException {


        // 1. 打开流
        DataInputStream in = new DataInputStream(new FileInputStream("e:/03chenhaisheng/1.txt"));
        testWrite();
         //2. 读取
        System.out.println(in.readInt());
        System.out.println(in.readByte());
        System.out.println(in.readInt());
        System.out.println(in.readInt());
        System.out.println(in.readInt());


        // 3. 关闭
        in.close();


    }

    private static void testWrite() throws IOException {
        // TODO Auto-generated method stub
        // 1. 打开流
        DataOutputStream out = new DataOutputStream(new FileOutputStream("e:/03chenhaisheng/1.txt"));

        // 2. 写入数据
        //out.write("编号，姓名，语文，数学，英语".getBytes());
        out.writeInt(1);
        //out.writeBytes("张三");
        out.writeInt(89);
        out.writeInt(100);
        out.writeInt(97);

        out.writeBytes("\n");
        out.writeInt(2);
        //out.writeBytes("李四");
        out.writeInt(33);
        out.writeInt(64);
        out.writeInt(92);
        out.writeBytes("\n");

        out.writeInt(3);
       // out.writeBytes("王五");
        out.writeInt(89);
        out.writeInt(100);
        out.writeInt(97);

        // 3. 关闭文件
        out.close();
    }

}
